import React, {Component} from 'react';
import request from "../utils/request";

export default class Film extends Component {
  state = {
    list: []
  }

  componentDidMount() {
    request("https://m.maizuo.com/gateway?cityId=440100&pageNum=1&pageSize=10&type=1&k=5792864", {
      headers: {
        'X-Client-Info': '{"a":"3000","ch":"1002","v":"5.2.0","e":"1640782700594797135921153","bc":"440100"}',
        'X-Host': 'mall.film-ticket.film.list'
      }
    }).then(res => {
      console.log(res.data.data)
      this.setState({
        list: res.data.data.films
      })
    })
  }

  render() {
    return (
      <div>
        {this.state.list.map((item) =>
          <li key={item.filmId} onClick={() => {
            this.props.history.push(`/detail/${item.filmId}`)
          }}>{item.name}</li>)}
      </div>
    );
  }
}
